package com.jshoperxms.controller.api.langdu;

import com.jshoperxms.Response;
import com.jshoperxms.controller.mall.backstage.base.BaseTController;
import com.jshoperxms.controller.utils.enums.BaseEnums;
import com.jshoperxms.controller.utils.statickey.TagWords;
import com.jshoperxms.entity.AdvertiseT;
import com.jshoperxms.service.AdvertiseTService;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by sdywcd on 2018/11/6.
 * Des:
 */
@RestController
@RequestMapping("/api/adv")
public class AdvisterController extends BaseTController {

    @Resource
    private AdvertiseTService advertiseTService;


    /**
     * 获取首页的广告banner
     * @return
     */
    @RequestMapping(value="/findIndexAdvBanner",method= RequestMethod.POST)
    public ResponseEntity findIndexAdvBanner(){
        Map<String,Object> responsedata=new HashMap<>();
        Criterion criterion=Restrictions.eq(TagWords.STATUS, BaseEnums.DataUsingState.USING.getState());
        List<AdvertiseT>list=this.advertiseTService.findByCriteria(AdvertiseT.class,criterion, Order.desc(TagWords.UPDATETIME));
        responsedata.put(TagWords.BEANLIST,list);
        responsedata.put(TagWords.SUCCESS,true);
        return Response.success(responsedata);
    }
}

